﻿@model IEnumerable<PessModel.PAuthor>

@{
    ViewBag.Title = "Authors";
    PessModel.Archive archive=(PessModel.Archive)ViewBag.Archive;
    PessModel.PAuthor pauthor = new PessModel.PAuthor(){ArchiveID=archive.ID};
    ViewBag.AllowEdit = true;
    
    ViewBag.Format = archive.CountyCode;
    
    if (Model.Count() == 0)
    {
        pauthor = new PessModel.PAuthor()
        {
            ArchiveID = archive.ID,
            Country = archive.Country,
            EMail = archive.EMail,
            FirstName = archive.FirstName,
            LastName = archive.LastName,
            Order = 1,
            Organization = archive.SchoolName,
        };
    }
    ViewBag.DefaultAuthor = pauthor;
    }

<h2 style="margin-bottom:10px">Authors</h2>

<fieldset class="create">
    <legend></legend>
    <div class="heading" style="margin-top:-15px;">
        Authors Information
    </div>
    <form>
   @Html.Partial("_CreatePAuthor",Model)
    </form>
    <br />
    <div class="editor-btn">
        <input type="button" value="Submit" id="btnFinish" />
        <input type="hidden" value="@archive.ID" id="archiveid" />
        </div>
</fieldset>

@*<div id="operate_bottom" style="width:820px;text-align:left;padding-top:0px;padding-bottom:20px">
    @Html.ActionLink("Finish", "FinishNewProposal", "Author", new {id=archive.ID },null)   
</div>*@

<div id="dialog-message" title="Message">
<p>
    <span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;">Message</span>
    <span id="msg_in_dialog"></span>
</p>
</div>

<script type="text/javascript">
    $(document).ready(function () {

        $("#dialog-message").hide();

        $("#btnFinish").click(function (event) {
            $('#msg_in_dialog').html("Processing...<br/><br/><img src='@Url.Content("~/images/ajax-loader.gif")'>");
            $("#dialog-message").dialog({
                modal: true
            });
            $.ajax({
                url: "@Url.Action("FinishNewProposal", "Author")" ,
                type: "GET",
                data: {
                    id: $("#archiveid").val()
                },
                success: function (url) {
                    $('#msg_in_dialog').html("Changes saved.");
                    $("#dialog-message").dialog({
                        modal: true,
                        buttons: {
                            "Continue": function () {
                                window.location.href = url;
                                $(this).dialog("close");

                            }
                        }
                    });
                }
            });
        });


    });
</script>